package mytest.leetcode;

import java.util.Arrays;

public class P274 {

    public static void main(String[] args) {

        int[] nums = {3, 0, 6, 1, 5};
        Arrays.sort(nums);
//        System.out.println(Arrays.toString(nums));
        int h = 0;
        int i = nums.length - 1;
        while (i >= 0 && nums[i] > h) {
            h++;
            i--;
        }
        System.out.println(h);
    }

}

